/*
	ProductionBasic.h

	Define Basic Production class 

	@author Wolfhead
*/

#pragma once

#ifndef _PRODUCTION_BASIC_H_
#define _PRODUCTION_BASIC_H_


#include "wfx.h"
#include "../Token/TokenBasic.h"
#include "ProductionArg.h"
#include <vector>
#include <string>


MAKE_PTR(CProduction);

/*
	CProduction
	represent a production

	this class is mostly used internal
	it's data is mostly used at ProductionParseing and Debug

	And call CProductionIMPL's method in template method
*/
class CProduction
{
private:
    class IMPL;
public:

    CProduction(std::string str, boost::shared_ptr<IMPL> pIMPL);

    ~CProduction();

    /*
     *	These Api are used by GrammarAnalyze
     */
public:

	/*
	 *	Right
	 *	return the right part of the production
	 *	@return std::vector<Token_Type>&
	 */
    const std::vector<Token_Type>& Right();

	/*
	 *	Left
	 *	return the left part of the production
	 *	@return Token_Type
	 */
    const Token_Type Left();


    int Length();

    /*
    *	These Api are used by Parser
    */
public:

    int ArgLength();

    CTokenPtr Reduce(CProductionArgPtr pArgs);


    /*
    *	These Api are used by Logger
    */
public:

    const char* toString();


protected:

    int m_argLength;

    std::string m_String;

    std::vector<Token_Type> m_Right;

    Token_Type m_Left;

    boost::shared_ptr<IMPL> m_pImplement;

};

#endif // #define _PRODUCTION_BASIC_H_